ast-grep: Utility Rule
utils:内に書いたものは再利用可能になるらしい
code:yaml
# define util rules using utils field
utils:
# it accepts a string-keyed dictionary of rule object
is-literal: # rule-id
any: # actual rule object
- kind: 'false'
- kind: undefined
- kind: 'null'
- kind: 'true'
- kind: regex
- kind: number
- kind: string
rule:
any:
- matches: is-literal # reference the util!
- kind: array
has:
matches: is-literal # reference it again!
↑これはlocal utility rule
globalに定義したいなら